﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace CloudFranceTriple.Tests.Controllers
{
    [TestClass]
    public class UserControllerTest : UnitTestBase
    {
        [TestMethod]
        [TestCategory("UserManager")]
        public void UserController_Index()
        {

            // Arrange
            //HomeController controller = new HomeController();
            var controller = new CloudFranceTriple.WebRole.Areas.UserManager.Controllers.UserController(GetWebSecurity.Object);

            controller.ControllerContext = base.GetControllerContext.Object;

            var context =
                new Mock<HttpContextBase>(MockBehavior.Strict);

            controller.Url =
                new UrlHelper(new RequestContext(context.Object,
                new RouteData()), new RouteCollection());

            // Act
            var result = controller.Index() as ViewResult;

            // Il y a au moins un utilisateur dans la liste : celui qui fait le test !
            Assert.IsTrue((result.Model as List<CloudFranceTriple.Models.UserProfile>).Count > 0);

            // Assert
            Assert.IsNotNull(result);
        }
    }
}
